{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Test exported data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/yoyee/Documents/deepSfm\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import sys\n",
    "module_path = os.path.abspath(os.path.join('..'))\n",
    "if module_path not in sys.path:\n",
    "    sys.path.append(module_path)\n",
    "os.chdir('../')\n",
    "print(os.getcwd())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>.container { width:100% !important; }</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import logging\n",
    "\n",
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "\n",
    "from IPython.core.display import display, HTML\n",
    "display(HTML(\"<style>.container { width:100% !important; }</style>\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "data:  ['image', 'prob', 'desc', 'warped_image', 'matches', 'warped_prob', 'warped_desc', 'homography']\n",
      "data:  ['image', 'prob', 'desc', 'warped_image', 'matches', 'warped_prob', 'warped_desc', 'homography']\n",
      "data:  ['image', 'prob', 'desc', 'warped_image', 'matches', 'warped_prob', 'warped_desc', 'homography']\n",
      "keypoints:  [[109.17230684 283.03176337]\n",
      " [ 34.07878713 294.94217514]\n",
      " [129.87245847  91.09245099]\n",
      " [ 94.12839252  63.99860885]\n",
      " [ 64.90133487 262.08064939]]\n",
      "warped_keypoints:  [[ 64.88634469 262.05720991]\n",
      " [181.17106545 129.98775617]\n",
      " [ 43.23742922  76.90757325]\n",
      " [ 15.12823653 125.97053776]\n",
      " [ 16.90259865 135.89217377]]\n"
     ]
    }
   ],
   "source": [
    "file = 'logs/superpoint_coco_test/predictions/'\n",
    "for i in range(3):\n",
    "    data = np.load(file + str(i) + '.npz')\n",
    "    print(\"data: \", list(data))\n",
    "    image = data['image']\n",
    "    warped_image = data['warped_image']\n",
    "    real_H = data['homography']\n",
    "    keypoints = data['prob'][:,[1, 0]] # (y, x)\n",
    "    desc = data['desc']\n",
    "    warped_keypoints = data['warped_prob'][:,[1, 0]]\n",
    "    \n",
    "print(\"keypoints: \", keypoints[:5])\n",
    "print(\"warped_keypoints: \", warped_keypoints[:5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py36_pytorch",
   "language": "python",
   "name": "py36_pytorch"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
